#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int t;
	long long N;
	cin >> t;
	while(t--)
	{
		cin >> N;
		double ans1 = N*log10(static_cast<double>(N));
		long long ans2 = static_cast<long long>(ans1);
		double ans = ans1 - ans2;
		int left_digit = static_cast<int>(pow(10, ans));
		cout << left_digit << endl;
	}
}